//
//  BuynowView.m
//  firstpoint
//
//  Created by 泽中 on 2017/7/24.
//  Copyright © 2017年 xzcysoft. All rights reserved.
//

#import "BuynowView.h"

@implementation BuynowView
- (instancetype)initWithFrame:(CGRect)frame data:(NSDictionary*)data VC:(UIViewController*)VC{
    if (self = [super initWithFrame:frame]) {
        self.backgroundColor=[UIColor whiteColor];
        //
        _button=[UIButton buttonWithType:UIButtonTypeCustom];
        _button.frame=CGRectMake(self.mj_w-25, 10, 15, 15);
        [_button setImage:[UIImage imageNamed:@"spxqc"] forState:0];
        [self addSubview:_button];
        //标题
        _titleLab=[[UILabel alloc]initWithFrame:CGRectMake(10, 35, self.mj_w-20, 40)];
        _titleLab.text=@"遇见过的每个人 用过来人的口吻 讲接着缘分 演绎的那么残忍 挥霍多少人 才甘心忘掉心里的人";
        _titleLab.numberOfLines=0;
        _titleLab.textColor=LRRGBColor(68, 68, 68);
        _titleLab.font=[UIFont systemFontOfSize:14];
        [self addSubview:_titleLab];
        //价格
        _jiageLab=[[UILabel alloc]initWithFrame:CGRectMake(10, 85, width_screen-20, 20)];
        _jiageLab.text=@"4000元宝-2400金币";
        _jiageLab.textColor=[UIColor orangeColor];
        _jiageLab.font=[UIFont systemFontOfSize:20];
        [self addSubview:_jiageLab];
        //分割
        for (int i=0; i<2; i++) {
            UILabel*fengeLab=[[UILabel alloc]initWithFrame:CGRectMake(0, 115+130*i, self.mj_w, 1)];
            fengeLab.backgroundColor=LRRGBColor(231, 231, 231);
            [self addSubview:fengeLab];
        }
       
             //按钮
        UIScrollView*scrollView=[[UIScrollView alloc]initWithFrame:CGRectMake(0, 126, self.mj_w, 120)];
        [self addSubview:scrollView];
        NSArray*keyArr=[data allKeys];
        _payButtonViewNum=keyArr.count;
        for (int i=0; i<_payButtonViewNum; i++) {
            _paybuttonView=[[PayButtonView alloc]initWithFrame:CGRectMake(0, 60*i, self.mj_w, 60) data:data[keyArr[i]] VC:VC];
            _paybuttonView.title.text=keyArr[i];
            [scrollView addSubview:_paybuttonView];
        }
        scrollView.contentSize=CGSizeMake(0, _paybuttonView.mj_y+_paybuttonView.mj_h);

    }
    //购买数量
    UILabel*goumaiNum=[[UILabel alloc]initWithFrame:CGRectMake(10, 260, 150, 13)];
    goumaiNum.text=@"购买数量";
    goumaiNum.font=[UIFont systemFontOfSize:13];
    goumaiNum.textColor=LRRGBColor(68, 68, 68);
    [self addSubview:goumaiNum];
    _jiaJianButton = [[ATChooseCountView alloc] initWithFrame:CGRectMake(self.mj_w-110, 255, 90, 25)];
//    _jiaJianButton.center = CGPointMake(self.center.x, 200.0f);
    _jiaJianButton.countColor = [UIColor redColor];
    _jiaJianButton.canEdit = NO;
    [self addSubview:_jiaJianButton];
   //按钮
    _quedingButton=[UIButton buttonWithType:UIButtonTypeCustom];
    _quedingButton.backgroundColor=[UIColor orangeColor];
    _quedingButton.frame=CGRectMake(0, self.mj_h-50, self.mj_w, 50);
    [_quedingButton setTitle:@"确定" forState:0];
    [self addSubview:_quedingButton];
    return self;
}

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
